<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>深入理解 Netty 架构设计</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        /* 首字下沉效果 */
        .drop-cap::first-letter {
            float: left;
            font-size: 4.5rem;
            line-height: 3.5rem;
            padding-right: 0.5rem;
            margin-top: 0.5rem;
            font-weight: 700;
            color: #4f46e5;
            font-family: 'Noto Serif SC', serif;
        }
        
        /* 代码块美化 */
        pre {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            padding: 1.5rem;
            border-radius: 1rem;
            overflow-x: auto;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            position: relative;
        }
        
        pre code {
            color: #ffffff;
            font-size: 0.9rem;
            line-height: 1.6;
            font-family: 'Fira Code', monospace;
        }
        
        /* 卡片悬停效果 */
        .feature-card {
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }
        
        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
        }
        
        /* 渐变文字效果 */
        .gradient-text {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        /* 动画效果 */
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .animate-fadeInUp {
            animation: fadeInUp 0.8s ease-out;
        }
        
        /* 自定义滚动条 */
        ::-webkit-scrollbar {
            width: 10px;
        }
        
        ::-webkit-scrollbar-track {
            background: #f1f1f1;
        }
        
        ::-webkit-scrollbar-thumb {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 5px;
        }
        
        /* 标题装饰线 */
        .title-decoration {
            position: relative;
            display: inline-block;
        }
        
        .title-decoration::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 0;
            width: 100%;
            height: 4px;
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
    </style>
</head>
<body>
    <!-- Hero 区域 -->
    <section class="relative overflow-hidden bg-gradient-to-br from-purple-900 via-indigo-900 to-blue-900 text-white">
        <div class="absolute inset-0 bg-black opacity-50"></div>
        <div class="relative container mx-auto px-6 py-24 text-center">
            <h1 class="text-5xl md:text-7xl font-bold mb-6 animate-fadeInUp">
                深入理解 <span class="gradient-text bg-gradient-to-r from-yellow-400 to-pink-500">Netty</span> 架构设计
            </h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90 animate-fadeInUp" style="animation-delay: 0.2s;">
                <i class="fas fa-network-wired mr-2"></i>
                探索高性能网络通信框架的核心奥秘
            </p>
            <div class="flex justify-center space-x-8 text-lg animate-fadeInUp" style="animation-delay: 0.4s;">
                <div class="flex items-center">
                    <i class="fas fa-rocket mr-2"></i>
                    <span>高性能</span>
                </div>
                <div class="flex items-center">
                    <i class="fas fa-layer-group mr-2"></i>
                    <span>事件驱动</span>
                </div>
                <div class="flex items-center">
                    <i class="fas fa-code-branch mr-2"></i>
                    <span>异步非阻塞</span>
                </div>
            </div>
        </div>
        <div class="absolute bottom-0 left-0 right-0">
            <svg viewBox="0 0 1440 120" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M0 120L60 110C120 100 240 80 360 70C480 60 600 60 720 65C840 70 960 80 1080 85C1200 90 1320 90 1380 90L1440 90V120H1380C1320 120 1200 120 1080 120C960 120 840 120 720 120C600 120 480 120 360 120C240 120 120 120 60 120H0V120Z" fill="white"/>
            </svg>
        </div>
    </section>

    <!-- 主要内容区域 -->
    <main class="container mx-auto px-6 py-12 max-w-6xl">
        <!-- 引言 -->
        <section class="mb-16 bg-white rounded-2xl shadow-xl p-8 animate-fadeInUp">
            <p class="text-lg leading-relaxed text-gray-700 drop-cap">
                Netty 作为一个高性能的网络通信框架，其架构设计精巧且灵活，旨在处理高并发和大规模的网络通信场景。它不仅是一个简单的网络编程框架，更是现代分布式系统中不可或缺的基础设施。
            </p>
        </section>

        <!-- 架构概览 -->
        <section class="mb-16">
            <h2 class="text-4xl font-bold mb-8 text-center">
                <span class="title-decoration gradient-text">整体架构设计</span>
            </h2>
            
            <div class="bg-white rounded-2xl shadow-xl p-8 mb-8">
                <p class="text-lg mb-6 text-gray-700">
                    Netty 的整体架构设计遵循了"事件驱动"的模型，并使用了多层次的模块划分来实现高效的网络通信。
                </p>
                
                <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                    <div class="feature-card bg-gradient-to-br from-blue-50 to-indigo-100 p-6 rounded-xl">
                        <div class="text-3xl mb-4 text-indigo-600">
                            <i class="fas fa-network-wired"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-2 text-gray-800">NIO 模块</h3>
                        <p class="text-gray-600">Channel 作为网络连接的抽象，提供统一的 API 接口</p>
                    </div>
                    
                    <div class="feature-card bg-gradient-to-br from-purple-50 to-pink-100 p-6 rounded-xl">
                        <div class="text-3xl mb-4 text-purple-600">
                            <i class="fas fa-sync-alt"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-2 text-gray-800">线程模型</h3>
                        <p class="text-gray-600">EventLoop 实现高效的事件处理和任务调度</p>
                    </div>
                    
                    <div class="feature-card bg-gradient-to-br from-green-50 to-teal-100 p-6 rounded-xl">
                        <div class="text-3xl mb-4 text-green-600">
                            <i class="fas fa-exchange-alt"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-2 text-gray-800">数据编解码</h3>
                        <p class="text-gray-600">ChannelHandler 链式处理数据的编码和解码</p>
                    </div>
                    
                    <div class="feature-card bg-gradient-to-br from-yellow-50 to-orange-100 p-6 rounded-xl">
                        <div class="text-3xl mb-4 text-orange-600">
                            <i class="fas fa-memory"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-2 text-gray-800">内存管理</h3>
                        <p class="text-gray-600">ByteBuf 提供高效的内存分配和管理策略</p>
                    </div>
                    
                    <div class="feature-card bg-gradient-to-br from-red-50 to-pink-100 p-6 rounded-xl">
                        <div class="text-3xl mb-4 text-red-600">
                            <i class="fas fa-file-code"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-2 text-gray-800">协议实现</h3>
                        <p class="text-gray-600">支持多种网络协议的编解码实现</p>
                    </div>
                    
                    <div class="feature-card bg-gradient-to-br from-indigo-50 to-blue-100 p-6 rounded-xl">
                        <div class="text-3xl mb-4 text-indigo-600">
                            <i class="fas fa-tachometer-alt"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-2 text-gray-800">性能优化</h3>
                        <p class="text-gray-600">零拷贝、内存池等多种优化技术</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- 架构图 -->
        <section class="mb-16 bg-white rounded-2xl shadow-xl p-8">
            <h3 class="text-2xl font-bold mb-6 text-center gradient-text">Netty 架构关系图</h3>
            <div class="mermaid">
                graph TB
                    subgraph "应用层"
                        A[用户应用程序]
                    end
                    
                    subgraph "Netty 核心层"
                        B[Bootstrap/ServerBootstrap]
                        C[EventLoopGroup]
                        D[Channel]
                        E[ChannelPipeline]
                        F[ChannelHandler]
                    end
                    
                    subgraph "传输层"
                        G[NIO Transport]
                        H[Epoll Transport]
                        I[OIO Transport]
                    end
                    
                    subgraph "缓冲层"
                        J[ByteBuf]
                        K[ByteBufAllocator]
                    end
                    
                    A --> B
                    B --> C
                    C --> D
                    D --> E
                    E --> F
                    D --> G
                    D --> H
                    D --> I
                    F --> J
                    J --> K
                    
                    style A fill:#f9f,stroke:#333,stroke-width:2px
                    style B fill:#bbf,stroke:#333,stroke-width:2px
                    style C fill:#bbf,stroke:#333,stroke-width:2px
                    style D fill:#bbf,stroke:#333,stroke-width:2px
                    style E fill:#bbf,stroke:#333,stroke-width:2px
                    style F fill:#bbf,stroke:#333,stroke-width:2px
                    style G fill:#bfb,stroke:#333,stroke-width:2px
                    style H fill:#bfb,stroke:#333,stroke-width:2px
                    style I fill:#bfb,stroke:#333,stroke-width:2px
                    style J fill:#fbb,stroke:#333,stroke-width:2px
                    style K fill:#fbb,stroke:#333,stroke-width:2px
            </div>
        </section>

        <!-- Boss-Worker 模式 -->
        <section class="mb-16">
            <h2 class="text-4xl font-bold mb-8 text-center">
                <span class="title-decoration gradient-text">主从模式设计</span>
            </h2>
            
            <div class="bg-white rounded-2xl shadow-xl p-8">
                <div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
                    <div>
                        <h3 class="text-2xl font-bold mb-4 flex items-center">
                            <i class="fas fa-crown mr-3 text-yellow-500"></i>
                            Boss 线程组
                        </h3>
                        <p class="text-gray-700 mb-4">
                            负责监听和接受客户端的连接请求。Boss 线程不做数据的读写，只负责分配连接，就像一个专业的接待员，将客户引导到合适的服务人员那里。
                        </p>
                        <div class="bg-gray-100 p-4 rounded-lg">
                